package com.virtusa.vcarpool.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

//import org.springframework.web.servlet.mvc.multiaction.MultiActionController;


@Controller
public class UserController   {

	
	@RequestMapping("/loginCheck.htm")
	public ModelAndView loginCheck(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String str = "{success:true}";  
		JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON( str );  
	    String userName=request.getParameter("loginUsername");
	    String loginPassword=request.getParameter("loginPassword");
	    
	    if(userName.equalsIgnoreCase("user") && loginPassword.equalsIgnoreCase("user")){
		return new ModelAndView("status", "status",jsonObject);
	    }
	    else {
	    	return new ModelAndView("status", "status","{success:false,errors:{reason:'Login failed.Try again'}}");
	    }
	}
	
	
	
}